<?php
/**
 * Author Yulin
 * Email  dwzhanglong@126.com
 * Date   2017-7-21
 * Func   资讯信息
 */
defined('IN_YuLin') || exit('NO PERMIT!');

$table = Table('article');
$ctable = Table('article_category');
$ltable = Table('lottery');

$id = intval($_GET['id']);
$cid = intval($_GET['cid']);

//	分类
$cids = [4,5,6,7,9];
$categorys = $db->getall('SELECT * FROM '.$ctable.' WHERE id IN ('.implode(',',$cids).')','id');

//	彩票规则只有内容页
if($id == 9 && $a != 'view')
{
	$a = 'view';
	//$cid = $lottery[0]['id'];
	$cid = current($lottery)['id'];
}

//	内容页
if($a == 'view')
{
	(!$id && !$cid) && ShowMsg('查看的信息不存在！',U());
	
	if($cid)	//	彩票规则
	{
		$data = $db->getrow('SELECT * FROM '.$table.' WHERE cid = 9 AND lotteryid = '.$cid.' AND status = 1');
		!$data && ShowMsg('查看的信息不存在！',U());
	}
	else
	{
		$data = $db->getrow('SELECT * FROM '.$table.' WHERE id = '.$id.' AND status = 1');
		!$data && ShowMsg('查看的信息不存在！',U());
	}
	
	$tpl->display('index/news_view');
	exit;
}

$data = $db->getall('SELECT * FROM '.$table.' WHERE cid = '.$id.' AND status = 1 ORDER BY id');

$tpl->display('index/news');